package com.hty.PowerChat;

import java.util.LinkedList;
import java.util.List;

import android.app.Activity;
import android.app.Application;
import android.content.Context;

public class MainApplication extends Application {
    private static Context mContext;
    private final List<Activity> activityList = new LinkedList<>();
    private static MainApplication instance;
    private static String uploadServer = "";

    //static ChatClient chatClient = null;
    //static String msg = "";
    //static long from = -1, to = -1;
    //static HashMap<String, Object> userData;

    @Override
    public void onCreate() {
        super.onCreate();
        mContext = getApplicationContext();
    }

    //public static void setmsg(String s) {
    //    msg = s;
    //}

    //public static String getmsg() {
    //    return msg;
    //}

    public static String getUploadServer() {
        return uploadServer;
    }

    public static Context getContext() {
        return mContext;
    }

    static MainApplication getInstance() {
        if (null == instance) {
            instance = new MainApplication();
        }
        return instance;
    }

    public void addActivity(Activity activity) {
        activityList.add(activity);
    }

    public void exit() {
        for (Activity activity : activityList) {
            activity.finish();
        }
        System.exit(0); // 杀进程释放内存
    }
}